"""财务页面"""
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class FinancialPage(BasePage):

    url='http://192.168.1.38/crm/index.php?m=finance'
    # 添加应收款定位器
    add_ysk_locator = (By.XPATH, "/html/body/div[5]/div[2]/div[1]/div[3]/a[1]")
    # 末页
    zuihouyiye_locator = (By.LINK_TEXT, '末页')
    # 首页
    first_page_locator = (By.CSS_SELECTOR,'#form1 > table > tfoot > tr:nth-child(2) > td > div.pagination > div.span4 > div > ul > li:nth-child(1) > span')
    #应收款
    yingshoukuan_locator = (By.CSS_SELECTOR, 'body > div.container > div.page-header > ul > li.active > a')
    #统计
    cwtj_locator = (By.CSS_SELECTOR, 'body > div.container > div.page-header > ul > li:nth-child(5) > a')
    # 添加收款单
    add_shoukuandan_locator = (By.XPATH, '/html/body/div[5]/div[2]/div[1]/div[3]/a[2]')
    # 今日应收
    today_locator = (By.XPATH, '/html/body/div[5]/p/a[9]')
    # 选择统计内容
    tjneirong_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div.span2.knowledgecate > ul > li.active > a')
    # 月度统计
    yuedutj_locator = (By.CSS_SELECTOR, '#show_moon')
    # 统计报表
    cwtj_baobiao_locator = (By.XPATH, '//*[@id="show_report"]')
    #年度统计
    nainduyfk_locator = (By.CSS_SELECTOR, '#show_fukuan')
    #断言添加成功
    duanyan_add_success_locator=(By.CLASS_NAME,'alert-success')
    #财务信息月度统计
    cw_yuedutj_locator=(By.CSS_SELECTOR,'#highcharts-0 > svg > text.highcharts-title')
    #应付款年度同比
    cw_niandutj_locator=(By.CSS_SELECTOR,'#highcharts-4 > svg > text.highcharts-title')


    """"点击应收款"""
    def click_ysk(self):
        self.driver.find_element(*self.yingshoukuan_locator).click()

    """点击添加应收款"""
    def click_add_ysk(self):
        self.driver.find_element(*self.add_ysk_locator).click()

    """点击末页"""
    def click_ysk_zuihouyiye(self):
        self.driver.find_element(*self.zuihouyiye_locator).click()

    """点击首页"""
    def click_ysk_shouye(self):
        self.driver.find_element(*self.first_page_locator).click()

    """点击统计"""
    def click_cw_tj(self):
        self.driver.find_element(*self.cwtj_locator).click()
    """选择统计内容"""
    def click_cwtj_neirong(self):
        self.driver.find_element(*self.tjneirong_locator).click()

    """选择财务统计报表"""
    def click_cwtj_baobiao(self):
        self.driver.find_element(*self.cwtj_baobiao_locator).click()

    """选择月度统计"""
    def click_cwtj_yuedutj(self):
        self.driver.find_element(*self.yuedutj_locator).click()

    """选择应付款年度同比"""
    def click_cwtj_niandutj(self):
        self.driver.find_element(*self.nainduyfk_locator).click()

    """点击新建收款单"""
    def click_add_shoukuandan(self):
        self.driver.find_element(*self.add_shoukuandan_locator).click()
    """点击今日应收"""
    def click_todayshoude(self):
        self.driver.find_element(*self.today_locator).click()


    """断言添加成功"""
    def tips_add_ysk_success(self):
        tips=self.driver.find_element(*self.duanyan_add_success_locator).text
        return tips
    """财务信息月度统计"""
    def message_yuedutj(self):
        yuedutj = self.driver.find_element(*self.cw_yuedutj_locator).text
        return yuedutj

    """"应付款年度同比"""
    def message_niandutj(self):
        niandutj = self.driver.find_element(*self.cw_niandutj_locator).text
        return niandutj

